/*
 * GetRootNode.java
 *
 * Created on 26 ตุลาคม 2550, 21:28 น.
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package anything;

import org.w3c.dom.*;
import javax.xml.parsers.*;
import java.io.*;
/**
 *
 * @author User
 */
public class GetRootNode {
  
  /** Creates a new instance of GetRootNode */
  public GetRootNode() {
  }
  
  public static void main(String[] args) {
    try {
      /*BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
      System.out.print("Enter xml file name: ");
      String str = bf.readLine();*/
      File file = new File("res/test/Employee-Detail.xml");
      if(file.exists()) {
        DocumentBuilderFactory fact = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = fact.newDocumentBuilder();
        Document doc = builder.parse(file);
        Node node = doc.getDocumentElement();
        String root = node.getNodeName();
        System.out.println("Root Node: "+root);
      }
      else {
        System.out.println("File not found.");
      }
    }
    catch(Exception e) {
      e.printStackTrace();
    }
  }
}
